package com.example.activemqpub.webcontroller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * \* @author: wky
 * \* Date: 2022/10/08
 * \* Time: 14:26
 * \* To change this template use File | Settings | File Templates.
 * \* Description:SendMsg
 * \
 */
@RestController
public class SendMsg {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @RequestMapping("/sendmsg")
    //private String sendMsg(@RequestBody TopicMssage msg) {
    private String sendMsg(@RequestParam String msg) {
        String topic = "mytopic";
        jmsMessagingTemplate.convertAndSend(topic, msg);

        return "send <topic:" + topic + ">,<msg:" + msg + ">,OK!";
    }

}